/**
 * Setup Carousel On Click Behavior
 * 
 */
$(function(){
	
	$("#contactCarousel").find("div.item").click(function(data){
		var keys = new Array();
		// Get All selected Lines
		var id = $(this).attr("id");
		var $container  = $("#main-container");
		$container.reloading({'append' : false});
		$("#contactCarousel").find("div.item").removeClass("active");
		$(this).addClass("active");
		$.ajax({
			type: "GET",
			url: "?mod=ressource&act=main&carousel=true&xvtrs=none&rid="+id,
			success: function(data)
			{
				$('#rlbox').remove();
				$container.empty().append($(data));
				var App = new Fx.Application($container);
			}	
		});
	});
});

function CarouselRemoveItem(itmid) {
	// Find Current Item
	$currentItem = $("#"+itmid);
	// Parent Container
	$parentContainer = $currentItem.parent();
	//var currentIndex = $parentContainer($currentItem).index();
	// Find Next Item if there is one
	var $nextItem = $currentItem.next();
	if($nextItem.length == 0) {
		$nextItem = $currentItem.prev();
	}
	if($nextItem.length == 0) {
		window.location.replace('?mod=ressource&act=search');
	}
	else {
		// Click on next and remove old item
		$nextItem.click();
		$currentItem.remove();
	}
}